// import Vue from 'vue';
// import VRouter from 'vue-router';
const VRouter = require('vue-router');

// Vue.use(VRouter);

// 路由懒加载 () => import('url')
export default new VRouter({
  mode: 'history',
  routes: [
    // 重定向
    {
      path: '/',
      redirect: '/home'
    },
    // 登录
    {
      path: '/login',
      name: 'login',
      component: () => import('@/pages/login/index.vue')
    },
    // 主界面
    {
      path: '/home',
      component: () => import('@/pages/home/index.vue'),
      redirect: '/home/index',
      // 子路由
      children: [
        // 系统主页
        {
          path: '/home/index',
          component: () => import('@/pages/system/index.vue'),
          // auth：验证 keep：缓存
          meta: {
            auth: true,
            keep: false
          }
        },
        // 菜单目录
        {
          path: '/home/menus',
          component: () => import('@/pages/menus/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 用户中心
        {
          path: '/home/users',
          component: () => import('@/pages/users/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 个人中心
        {
          path: '/home/userinfo',
          component: () => import('@/pages/userinfo/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 公司列表
        {
          path: '/home/company',
          component: () => import('@/pages/company/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 部门列表
        {
          path: '/home/department',
          component: () => import('@/pages/department/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 员工列表
        {
          path: '/home/users',
          component: () => import('@/pages/users/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 入离调转
        {
          path: '/home/resignation',
          component: () => import('@/pages/resignation/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 考勤工时
        {
          path: '/home/attendance',
          component: () => import('@/pages/attendance/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 工时导入
        {
          path: '/home/staffHours',
          component: () => import('@/pages/staffHours/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 权限设置
        {
          path: '/home/permissions',
          component: () => import('@/pages/permissions/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 角色列表
        {
          path: '/home/role',
          component: () => import('@/pages/role/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 系统日志
        {
          path: '/home/syslog',
          component: () => import('@/pages/syslog/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 发布版本
        {
          path: '/home/syslog/addLog',
          component: () => import('@/pages/syslog/addLog/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 用户日志
        {
          path: '/home/userlog',
          component: () => import('@/pages/userlog/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 消息通知
        {
          path: '/home/message',
          component: () => import('@/pages/message/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 审批角色
        {
          path: '/home/flowRole',
          component: () => import('@/pages/flowRole/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程模型
        {
          path: '/home/processModel',
          component: () => import('@/pages/processModel/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程模型设计
        {
          path: '/home/processDesign',
          component: () => import('@/pages/processDesign/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 我的申请
        {
          path: '/home/reqFlow',
          component: () => import('@/pages/reqFlow/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 我的待办
        {
          path: '/home/waitFlow',
          component: () => import('@/pages/waitFlow/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 我的已办
        {
          path: '/home/doFlow',
          component: () => import('@/pages/doFlow/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 进行中的流程
        {
          path: '/home/flowing',
          component: () => import('@/pages/flowing/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 结束的流程
        {
          path: '/home/flowed',
          component: () => import('@/pages/flowed/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 表单模型
        {
          path: '/home/formModel',
          component: () => import('@/pages/formModel/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 口径设置
        {
          path: '/home/category',
          component: () => import('@/pages/category/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 归集设置
        {
          path: '/home/summarize',
          component: () => import('@/pages/summarize/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 归集历史
        {
          path: '/home/sumlog',
          component: () => import('@/pages/sumlog/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 项目立项
        {
          path: '/home/addpro',
          component: () => import('@/pages/addpro/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 项目列表
        {
          path: '/home/prolist',
          component: () => import('@/pages/prolist/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 项目信息
        {
          path: '/home/prolist/proinfo',
          component: () => import('@/pages/prolist/proinfo/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 添加/修改  项目费用数据
        {
          path: '/home/prolist/proinfo/money',
          component: () => import('@/pages/prolist/proinfo/money/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 添加/修改  项目成员数据
        {
          path: '/home/prolist/proinfo/members',
          component: () => import('@/pages/prolist/proinfo/members/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 上传/修改 项目合同信息
        {
          path: '/home/prolist/proinfo/contract',
          component: () => import('@/pages/prolist/proinfo/contract/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 上传/修改 项目验收报告
        {
          path: '/home/prolist/proinfo/acceptance',
          component: () => import('@/pages/prolist/proinfo/acceptance/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 上传/修改 项目文档资料
        {
          path: '/home/prolist/proinfo/file',
          component: () => import('@/pages/prolist/proinfo/file/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 项目成本明细
        {
          path: '/home/prolist/proinfo/cost',
          component: () => import('@/pages/prolist/proinfo/cost/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 添加项目成员
        {
          path: '/home/prolist/proinfo/staff',
          component: () => import('@/pages/prolist/proinfo/staff/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 客户部门
        {
          path: '/home/cusdept',
          component: () => import('@/pages/cusdept/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 客户列表
        {
          path: '/home/customer',
          component: () => import('@/pages/customer/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 客户分组
        {
          path: '/home/cusgroup',
          component: () => import('@/pages/cusgroup/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 客户授信表
        {
          path: '/home/credibility',
          component: () => import('@/pages/credibility/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 客户通讯录
        {
          path: '/home/contact',
          component: () => import('@/pages/contact/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 员工工时
        {
          path: '/home/hours',
          component: () => import('@/pages/hours/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 我的工时
        {
          path: '/home/myHours',
          component: () => import('@/pages/myHours/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程类页面-立项申请
        {
          path: '/home/reqFlow/project/setUp',
          component: () => import('@/pages/Tbl/project/setUp/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程类页面-添加立项申请
        {
          path: '/home/reqFlow/project/addSetUp',
          component: () => import('@/pages/Tbl/project/addSetUp/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程类页面-现金报销
        {
          path: '/home/reqFlow/work/cash',
          component: () => import('@/pages/Tbl/work/cash/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程类页面-添加现金报销
        {
          path: '/home/reqFlow/work/addCash',
          component: () => import('@/pages/Tbl/work/addCash/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程类页面-差旅报销
        {
          path: '/home/reqFlow/work/travel',
          component: () => import('@/pages/Tbl/work/travel/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程类页面-添加差旅报销
        {
          path: '/home/reqFlow/work/addTravel',
          component: () => import('@/pages/Tbl/work/addTravel/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 流程类页面-测试
        {
          path: '/home/leave',
          component: () => import('@/pages/leave/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 资产管理-资产类目
        {
          path: '/home/assetsType',
          component: () => import('@/pages/assetsType/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        },
        // 资产管理-资产列表
        {
          path: '/home/assetsTable',
          component: () => import('@/pages/assetsTable/index.vue'),
          meta: {
            auth: true,
            keep: false
          }
        }
      ]
    },
    // 资产详情页
    {
      path: '/home/assetInfo/:assetCode?',
      component: () => import('@/pages/assetsTable/info/index.vue')
    },
    // 错误页面
    {
      path: '/404',
      name: '404',
      component: () => import('@/pages/error/404.vue')
    }
  ]
});

/**
 * 重写路由的push方法
 */
const routerPush = VRouter.prototype.push;

VRouter.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error);
};
